<?php

/**
 * Consulta filter form base class.
 *
 * @package    dentist
 * @subpackage filter
 * @author     Brus
 */
abstract class BaseConsultaFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'paciente_id'    => new sfWidgetFormPropelChoice(array('model' => 'Paciente', 'add_empty' => true)),
      'consultorio_id' => new sfWidgetFormPropelChoice(array('model' => 'Consultorio', 'add_empty' => true)),
      'fecha'          => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'hora'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'trabajo'        => new sfWidgetFormFilterInput(),
      'costo'          => new sfWidgetFormFilterInput(),
      'pago'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'usuario_id'     => new sfWidgetFormPropelChoice(array('model' => 'Usuario', 'add_empty' => true)),
      'created_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'updated_at'     => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'paciente_id'    => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Paciente', 'column' => 'id')),
      'consultorio_id' => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Consultorio', 'column' => 'id')),
      'fecha'          => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'hora'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'trabajo'        => new sfValidatorPass(array('required' => false)),
      'costo'          => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'pago'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'usuario_id'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Usuario', 'column' => 'id')),
      'created_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'     => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('consulta_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Consulta';
  }

  public function getFields()
  {
    return array(
      'id'             => 'Number',
      'paciente_id'    => 'ForeignKey',
      'consultorio_id' => 'ForeignKey',
      'fecha'          => 'Date',
      'hora'           => 'Date',
      'trabajo'        => 'Text',
      'costo'          => 'Number',
      'pago'           => 'Boolean',
      'usuario_id'     => 'ForeignKey',
      'created_at'     => 'Date',
      'updated_at'     => 'Date',
    );
  }
}
